<?php
namespace Home\Controller;
use Think\Controller;

class CommonController extends Controller
{
    public function _initialize()
    {
        $login_user_id = session("user_id");
        $res = session('url_shop_id');


        if(!$login_user_id){
            $this->redirect('Login/index', array('shop_id'=>$res));
        }
        $shop_id = M('agent')->where(array('agent_id'=>$login_user_id))->getField('shop_id');
        if(!$shop_id){
            $this->redirect('Login/index', array('shop_id'=>$res));
        }

        if($shop_id !== session("url_shop_id")){
            $this->redirect('Login/index', array('shop_id'=>$res));
        }


        //$name = M('theme')->where( array('is_default'=>1) )->getField('name');
        $this->theme(C('NOW_THEME'));
        $this->assign('theme', C('NOW_THEME'));
        //echo $name;
    }

}